const axios = require('axios').default
// exports.convertTime = function (time) {
//   function _convert(decimal) {
//     const m = Math.floor(decimal / 60)
//     decimal = decimal - m * 60
//     const s = decimal
//     let ret =
//       (m < 10 ? '0' : '') + m + ':'
//       + (s < 10 ? '0' : '') + s
//     return ret
//   }
//   const decimal = Math.floor(time)
//   const fraction = time - decimal
//   let temp = (fraction + 0.0001).toString().substring(2, 5)
//   return _convert(decimal) + '.' + temp
// }

exports.convertTime = function (time) {
  function _convert(decimal) {
    const m = Math.floor(decimal / 60)
    decimal = decimal - m * 60
    const s = decimal
    let ret =
      (m < 10 ? '0' : '') + m + ':'
      + (s < 10 ? '0' : '') + s
    return ret
  }
  const decimal = Math.floor(time)

  return _convert(decimal)
}


exports.getRandomMusicData = function () {
  return new Promise((resolve, reject) => {
    axios.get('https://anime-music.jijidown.com/api/v2/music').then((res) => {
      resolve(res.data.res)
    }).catch(err => {
      reject(err)
    })
  })
}

